<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <script src="JS/jquery.js"></script>
        <script type="text/javascript" src="http://connect.facebook.net/en_US/all.js" ></script>


        <script>
            token={"access_token":"127410177333318|b7108180a43840ce27170a25.1-1198560721|exMFd0oi8aDMw3mPmP-JUamQkF4"}//azouz
            //   token={"access_token":"127410177333318|b41a194651efdc771e9bc191.1-696821500|0qiIry4BLhw2VSzD8jHt35EgtlY"}//haway
           //token={"access_token":"127410177333318|df4bc0bfd6863599569fa0be.1-100002298398209|xYGLIEhEcTvEL4S0uFN831jeqDQ"}//fbchat
           //token={"access_token":"102201119868199|8d35f8c01381c715ede117c4.1-100001513410529|cJWhrjTYPuTxIFrRLnoNqUhtMKM"}//azouz
            function getUser(callback){
                FB.api('/me/friends',{
                    access_token:token.access_token//new session key
                }, function(data) {
                    callback(data.data);
                })
            }

            function getDetails(id,callback){
                FB.api(
                {
                    method: 'fql.query',
                    query: "SELECT uid,online_presence,name  FROM user WHERE  uid ="+id,
                    access_token:token.access_token
                },
                function(data) {
                    callback(data);
                });
            }
            var user =[];
            var onlineuser =[];
            var idleuser =[];
            function getInfo(callback){
                getUser(function(res){
                    var online=0;
                    for(i=0;i<res.length;i++){
                        getDetails(res[i].id,function(res){
                            user.push(res)
                            if(res[0].online_presence=="active"){
                                onlineuser.push(res)
                                callback(++online)
                            }
                            if(res[0].online_presence=="idle"){
                                idleuser.push(res)
                            }
                        });
                    }
                    
                })
            }
            getInfo(function(online){
                $("#online").html(online)
                //$("#onlineuser").html(JSON.stringify(onlineuser))
                //$("#idleuser").html(JSON.stringify(idleuser))

                                $("#name").html(JSON.stringify(user));
            })
        </script>
    </head>
    <body>
        <div id="online"></div>
        <div id="onlineuser"></div>

        <div id="idleuser"></div>


        <div id="name"></div>


    </body>
</html>
